package com.space.client.domainevent;

import com.space.component.client.DomainEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.messaging.Message;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Locale;
import java.util.function.Function;

/**
 * @author <a href="mailto:414563035@qq.com">Bedroom</a>
 * @date 2021/4/27 7:15 下午
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CreateUserAccountEvent implements DomainEvent {
    private final static String TAG = CreateUserAccountEvent.class.getSimpleName().toUpperCase(Locale.ROOT);
    private final static String TOPIC = "USER_INFO";
    @Override
    public String getTag() {
        return TAG;
    }

    @Override
    public String getTopic() {
        return TOPIC;
    }

    private Integer userId;

    @FunctionalInterface
    public interface Consumer {
        /**
         * 规范消费者名称
         * 一般和Tag或者类同名
         * @return void
         */
        Function<Flux<Message<CreateUserAccountEvent>>, Mono<Void>> createUserAccountEvent();
    }
}
